const Koa = require('koa');
const Router = require('koa-router')
const app = new Koa();
const router = new Router();
const body = require('koa-body')
const utils = require('./utils')

console.log(utils, 'u')
app.use(body())
app.use(router.routes());
app.use(router.allowedMethods())


router.get('/users', ctx => {
    ctx.body = {
        data: [],
        message: '增加1行代码测试的内容',
        errno: 0
    }
})

router.post('/users', ctx => {
    const value = utils.addUser(ctx.request.body)
    ctx.body = {
       errno: 0,
       message: value ? '添加成功' : '已存在'
    }
})

app.listen(3333)